#!/bin/sh
# postrm script for openmediavault-mysql
#
# $Id: postrm 47 2011-11-29 20:20:36Z imooreyahoo@gmail.com $
#

set -e

. /etc/default/openmediavault
. /usr/share/openmediavault/scripts/helper-functions

if [ "$1" = "purge" ]; then

	KEYDIR=$(omv_config_get "//services/openvpn/keydir")
	
	# Check for XML config
	if omv_config_exists "//services/openvpn"; then
		xmlstarlet ed -P -L -d "//services/openvpn" ${OMV_CONFIG_FILE}
	fi

	# Remove OpenVPN group
	groupdel openvpn
	omv_config_delete_group "openvpn"

	# Remove keydir?
	if [ `echo "${KEYDIR}" | grep -c "openvpn-keystore"` -gt 0 ]; then
		/bin/rm -rf ${KEYDIR}
	fi
			
fi

exit 0
